-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(nodeScaleDownTime): add a new metric to track unprocessed nodes during scaleDown #8614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(nodeScaleDownTime): add a new metric to track unprocessed nodes during scaleDown #8614
Conversation
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Welcome @shaikenov! |
Hi @shaikenov. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very good
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kada2004, shaikenov The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
… nodes during scaleDown
b9e7969
to
86a98d1
Compare
} | ||
|
||
type longestNodeScaleDownTime struct { | ||
defaultTime time.Time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's maybe rename it to sth more meaningful: evalTime, lastEvalTime, ...?
l.nodeNamesWithTimeStamps = make(map[string]time.Time) | ||
metrics.ObserveLongestNodeScaleDownTime(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should report the biggest time (if there were any carry over from the previous loop) before clearing it.
Also l.defaultTime
should be updated here.
Please add a unit test for this scenario.
nodes := make([]*apiv1.Node, tc.nodes) | ||
for i := 0; i < tc.nodes; i++ { | ||
nodes[i] = BuildTestNode(fmt.Sprintf("n%d", i), 1000, 10) | ||
} | ||
provider := testprovider.NewTestCloudProviderBuilder().Build() | ||
provider.AddNodeGroup("ng1", 0, 0, 0) | ||
for _, node := range nodes { | ||
provider.AddNode("ng1", node) | ||
} | ||
context, err := NewScaleTestAutoscalingContext(config.AutoscalingOptions{ | ||
NodeGroupDefaults: config.NodeGroupAutoscalingOptions{ | ||
ScaleDownUnneededTime: 1 * time.Minute, | ||
}, | ||
ScaleDownSimulationTimeout: 1 * time.Hour, | ||
MaxScaleDownParallelism: 10, | ||
LongestNodeScaleDownTimeTrackerEnabled: true, | ||
}, &fake.Clientset{}, nil, provider, nil, nil) | ||
assert.NoError(t, err) | ||
clustersnapshot.InitializeClusterSnapshotOrDie(t, context.ClusterSnapshot, nodes, nil) | ||
deleteOptions := options.NodeDeleteOptions{} | ||
p := New(&context, processorstest.NewTestProcessors(&context), deleteOptions, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be easier to just create instance with newLongestNodeScaleDownTime()?
var timestamp time.Time | ||
|
||
// take nodes "n0" - "n3" as unneeded | ||
unneededNodeNames := tc.unneededNodes1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need unneededNodeNames
variable?
// if a node is already in nodeNamesWithTimeStamps copy the last value | ||
valueFromPrevIter := l.get(nodeName) | ||
newNodes[nodeName] = valueFromPrevIter | ||
if minimumTime.Compare(valueFromPrevIter) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: From what I see Compare() is not used here. Please use Before() or After().
return | ||
} | ||
newNodes := make(map[string]time.Time, len(nodeNames)) | ||
l.defaultTime = currentTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you override l.defaultTime
too early.
Let's imagine very simple scenario with one node:
time | unneeded | reportedTime | nodeNamesWithTimeStamps |
---|---|---|---|
t | [] | 0 | |
t+1 | [n1] | 1 | n1 : t |
t+2 | [n1] | 2 | n1 : t |
t+3 | [] | 3 | |
t+4 | [] | 0 |
Seems like with your implementation you would at t +1 save n1: t+1
and report 0.
Name: "longest_scale_down_eval", | ||
Help: "Longest node evaluation time during ScaleDown.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a unit as suffix (eg. like function_duration_seconds).
Have you checked what buckets are used by default and if they are fine for this use case?
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR adds a new metric to the exported prometheus metrics list: LongestNodeScaleDownTime
We want to track all the nodes that were marked as unneeded, but were unprocessed during the ScaleDown. If a node was unneeded, but unprocessed multiple times consecutively, we store only the earliest time it happened. The difference between the current time and the earliest time among all unprocessed nodes will give the longest time. This time can give us an indication of possible throttling and helps to better monitor what happens during ScaleDown.
Which issue(s) this PR fixes:
None
Special notes for your reviewer: this is a draft PR, work is still in progress
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
None